home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software of the Month Club 1999 October
/
Software of the Month - Ultimate Collection Shareware 266.iso
/
pc
/
Xtras
/
Animation Wizard.dir
/
00009_Script_Zooms
< prev
next >
Wrap
Text File
|
1997-05-10
|
13KB
|
421 lines
-- Zooms script
property ioFieldList
property iFieldFocus
property ioFieldFocus
property iCurrentMotionStyleIndex
property iCurrentVisualStyleIndex
-- The motion styles are:
property ikMotionIn -- 1
property ikMotionOut -- 2
property ikMotionOutThenIn -- 3
property ikMotionInThenOut -- 4
property iFirstTIme
property iSaveSeconds
property iSaveFPS
property iSaveBaseline
property iSaveDelayEnter
property iSaveDelayHold
property iSaveMark
property iSaveCycles
property iSaveSizeMin
property iSaveSizeMax
on birth me
global goZoomsText
global goSeconds
global goFPS
global goBaseLine
global goSizeMin
global goSizeMax
global goDelayEnter
global goDelayHold
global goCycles
set ioFieldList = [goZoomsText, goSeconds, goFPS, goSizeMin, goSizeMax,¼
goBaseLine, goDelayEnter, goDelayHold, goCycles]
set ikMotionIn = 1
set ikMotionOut = 2
set ikMotionOutThenIn = 3
set ikMotionInThenOut = 4
set iCurrentMotionStyleIndex = ikMotionIn
set iCurrentVisualStyleIndex = 1
set iFieldFocus = 1
set iFirstTime = TRUE
return me
end birth
on mInit me
global goSeconds
global goFPS
global goBaseLine
global goSizeMin
global goSizeMax
global goDelayEnter
global goDelayHold
global goCycles
global goZooms
global goMarkFrame
global goVisualStyles
global goMotionStyles
global goScoreMgr
-- CheckMark parameter: channel
mInit(goMarkFrame, 4) -- channel
if iFirstTime then -- use intellegent defaults
mSetValue(goSeconds, 5)
mSetValue(goFPS, 5)
set defaultBaseLine = integer(mGetStageHeight(goScoreMgr) / 2)
mSetValue(goBaseLine, defaultBaseLine)
mSetValue(goSizeMin, 1)
mSetValue(goSizeMax, 100)
mSetValue(goDelayEnter, 0)
mSetValue(goDelayHold, 0)
mSetValue(goCycles, 1)
mSetValue(goMarkFrame, TRUE)
set iFirstTime = FALSE
else -- use values saved from when we last left
mSetValue(goSeconds, iSaveSeconds)
mSetValue(goFPS, iSaveFPS)
mSetValue(goBaseLine, iSaveBaseline)
mSetValue(goSizeMin, iSaveSizeMin)
mSetValue(goSizeMax, iSaveSizeMax)
mSetValue(goDelayEnter, iSaveDelayEnter)
mSetValue(goDelayHold, iSaveDelayHold)
mSetValue(goCycles, iSaveCycles)
mSetValue(goMarkFrame, iSaveMark)
end if
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
-- RadioButtons parameters: channel, nChannels, rightAnswer, default
set goMotionStyles = 0
set goMotionStyles = birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
-- VisualStyles Params: castNum, default, nItems, channel
if the machineType < 256 then
mInit(goVisualStyles, the number of cast "ZoomsVisualStylesMac", ¼
iCurrentVisualStyleIndex, 8, 19)
else
mInit(goVisualStyles, the number of cast "ZoomsVisualStylesPC", ¼
iCurrentVisualStyleIndex, 8, 19)
end if
-- For keystroke validity checking
set the keydownscript = "mCheckKey(goZooms)"
end mInit
on mSetFieldFocus me, oWhom
set where = getOne(ioFieldList, oWhom)
if where = 0 then
alert("Internal error - mSetFieldFocus could not find object")
return
end if
set iFieldFocus = where
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
end mSetFieldFocus
on mCheckKey me
if the Key = TAB then -- change focus to the next field
set iFieldFocus = IncrMod(iFieldFocus, count(ioFieldList))
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
pass -- pass the event so the hilight goes to the next field
else
if iFieldFocus = 1 then -- the text entry field, allow anything
pass
else -- numeric fields, only allow digits
if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
pass
else
dontPassEvent -- restrict only to digits.
end if
end if
end if
end mCheckKey
on mSetNewMotionStyle me, theNewStyleIndex
set iCurrentMotionStyleIndex = theNewStyleIndex
end mSetNewMotionStyle
on mSetNewVisualStyle me, theNewStyleIndex
set iCurrentVisualStyleIndex = theNewStyleIndex
end mSetNewVisualStyle
on mValidate me
global goSizeMin
global goSizeMax
if mGetValue(goSizeMin) > mGetValue(goSizeMax) then
alert("The minimum size must be less than the maximum size.")
return FALSE
end if
-- Attempt to validate the last field of focus
set lastFieldOKFlag = mValidate(ioFIeldFocus)
return lastFieldOKFlag
end mValidate
on mCreate me
global goMarkFrame
global goMotionStyles
global goVisualStyles
global goScoreMgr
global goCastMgr
global gDevelopmentFlag
global gCastNumTextAsBitmap
global goPlatform
if not(mValidate(me)) then
return
end if
if field("ZoomsText") = EMPTY then
alert("Please enter some text for the Zoom.")
return
end if
tell the stage
set theStageFrame = the frame
end tell
set castNumVisualStyle = mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
set theVisualStyleName = the name of cast castNumVisualStyle
set theFont = word 2 of theVisualStyleName
set theSize = word 3 of theVisualStyleName
set theSeconds = integer(field "Seconds")
set fps = integer(field "FPS")
set baseLine = integer(field "BaseLine")
set delayEnter = integer(field "DelayEnter")
set delayHold = integer(field "DelayHold")
set nCycles = integer(field "Cycles")
set markFirst = mGetValue(goMarkFrame)
set sizeMin = integer(field "SizeMin")
set sizeMax = integer(field "SizeMax")
set nFrames = integer(theSeconds * fps)
-- Call the ScoreMgr to set up the score, # of frames, and 1 channel
-- set nTotalFrames = (delayEnter + nFrames + delayHold) * nCycles
if delayHold > 0 then
set nTotalFrames = (nFrames + 1)*nCycles
else
set nTotalFrames = nFrames*nCycles
end if
if not(mInit(goScoreMgr, nTotalFrames, 1)) then
return
end if
set theCh = mGetNextSelectedChannel(goScoreMgr)
set theFrameNum = mGetStartFrame(goScoreMgr)
set castNumSource = mModifyRichTextCM(goCastMgr, ¼
the text of field "ZoomsText", theFont, theSize)
if castNumSource = 0 then -- error
return
end if
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumSource
set widthOfTextAsBitmap = float(the width of member gCastNumTextAsBitmap)
set heightOfTextAsBitmap = float(the height of member gCastNumTextAsBitmap)
-- Do specific calculations depending on motion style
set pctMin = float(sizeMin) / 100.
set pctMax = float(sizeMax) / 100.
set pctInc = (pctMax - pctMin) / float(nFrames - 1)
if (iCurrentMotionStyleIndex = ikMotionIn) or (iCurrentMotionStyleIndex = ikMotionOut) then
set nFrames1 = nFrames
set nFrames2 = 0
else
set nFrames1 = integer(nFrames / 2)
set nFrames2 = nFrames - nFrames1
set pctInc = pctInc * 2 -- must double to do this in half the frames
end if
if (iCurrentMotionStyleIndex = ikMotionIn) or ¼
(iCurrentMotionStyleIndex = ikMotionInThenOut) then
set pctStart1 = pctMin
set pctInc1 = pctInc
set pctStart2 = pctMax
set pctInc2 = pctInc * -1.0
else -- Out or OutThenIn
set pctStart1 = pctMax
set pctInc1 = pctInc * -1.0
set pctStart2 = pctMin
set pctInc2 = pctInc
end if
set theForeColor = 255
set theBackColor = 0
-- Copy the cast member into the source movie's cast
set castNumTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member gCastNumTextAsBitmap
tell the stage
pasteClipboardInto member castNumTarget
set the name of member castNumTarget = "BitMap" && string(the ticks)
end tell
-- Finally we are ready to generate frames
-- initialize list of frames to record in
set frameList = []
repeat with i = theFrameNum to (theFrameNum + nTotalFrames - 1)
add(frameList, [i])
end repeat
-- Mark first frame upon request
if markFirst then
set firstFrame = getAt(frameList, 1)
set theLabel = "AW.Zoom." & word 1 of the text of field "ZoomsText" & " " & ¼
mGetGeneratedScoreSelection(goScoreMgr)
add(firstFrame, [#label, theLabel])
setAt(frameList, 1, firstFrame)
end if
-- Generate the score fragment
set relFrameCount = 1
repeat with thisCycle = 1 to nCycles
set xLoc = round(mGetStageWidth(goScoreMgr) / 2)
set yLoc = baseline
set currentPct = pctStart1
set theWidth = currentPct * widthOfTextAsBitmap
set theHeight = currentPct * heightOfTextAsBitmap
-- Insert delay at entry upon request
set firstFrame = getAt( frameList, relFrameCount)
set secondFrame = getAt( frameList, relFrameCount + 1)
if delayEnter > 0 then
add(firstFrame, [#tempo, -delayEnter])
add(secondFrame, [#tempo, fps])
else
add(firstFrame, [#tempo, fps])
add(secondFrame, [#tempo, 0])
end if
setAt(frameList, relFrameCount, firstFrame)
setAt(frameList,relFrameCount + 1, secondFrame)
-- Generate the first part of the zoom
repeat with thisFrame = 1 to nFrames1
set theWidth = integer(theWidth +.49)
set theHeight = integer(theHeight + .49)
set currentFrame = getAt(frameList,relFrameCount)
add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight ])
-- mWriteSpriteRange(goScoreMgr, theFrameNum, theCh, castNumTarget, ¼
-- theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight)
setAt(frameList, relFrameCount, currentFrame)
set theFrameNum = theFrameNum + 1
set currentPct = currentPct + pctInc1
set theWidth = currentPct * widthOfTextAsBitmap
set theHeight = currentPct * heightOfTextAsBitmap
set relFrameCount = relFrameCount + 1
end repeat
-- insert delay upon request
if delayHold > 0 then
set currentFrame = getAt(frameList,relFrameCount)
add(currentFrame, [#tempo, -delayHold])
set theWidth = integer(theWidth +.49)
set theHeight = integer(theHeight + .49)
add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight ])
-- mWriteSprite(goScoreMgr, theFrameNum, theCh, castNumTarget, ¼
-- theForeColor, theBackColor, xLoc, yLoc, integer(theWidth), integer(theHeight))
setAt(frameList, relFrameCount, currentFrame)
set theFrameNum = theFrameNum + 1
set relFrameCount = relFrameCount + 1
end if
-- Generate the second part of the zoom if there is one
if nFrames2 > 0 then
set currentPct = pctStart2
set theWidth = currentPct * widthOfTextAsBitmap
set theHeight = currentPct * heightOfTextAsBitmap
-- mWriteFrameTempo(goScoreMgr, theFrameNum, fps)
repeat with thisFrame = 1 to nFrames2
set theWidth = integer(theWidth +.49)
set theHeight = integer(theHeight + .49)
set currentFrame = getAt(frameList, relFrameCount)
add(currentFrame, [#sprite, theCh, castNumTarget, theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight ])
-- mWriteSpriteRange(goScoreMgr, theFrameNum, theCh, castNumTarget, ¼
-- theForeColor, theBackColor, xLoc, yLoc, theWidth, theHeight)
setAt(frameList, relFrameCount, currentFrame)
set theFrameNum = theFrameNum + 1
set currentPct = currentPct + pctInc2
set theWidth = currentPct * widthOfTextAsBitmap
set theHeight = currentPct * heightOfTextAsBitmap
set relFrameCount = relFrameCount + 1
end repeat
end if
end repeat -- nCycles
mWriteFrame(goScoreMgr, frameList)
set labelName = "Zooms" & goPlatform
go label(labelName) + 2 -- to display reselect button
if not(gDevelopmentFlag) then
tell the stage
go frame theStageFrame
end tell
end if
mClean(goScoreMgr)
end mCreate
on mCleanup me
global goMotionStyles
global goSeconds
global goFPS
global goBaseLine
global goSizeMin
global goSizeMax
global goDelayEnter
global goDelayHold
global goCycles
global goMarkFrame
mCleanup(goMotionStyles)
set iSaveSeconds = mGetValue(goSeconds)
set iSaveFPS = mGetValue(goFPS)
set iSaveBaseLine = mGetValue(goBaseLine)
set iSaveSizeMin = mGetValue(goSizeMin)
set iSaveSizeMax = mGetValue(goSizeMax)
set iSaveDelayEnter = mGetValue(goDelayEnter)
set iSaveDelayHold = mGetValue(goDelayHold)
set iSaveCycles = mGetValue(goCycles)
set iSaveMark = mGetValue(goMarkFrame)
mCleanup(goMarkFrame)
end mCleanup